/**
 * @file    yd1363_data.h
 * @brief   数据链路
 * @author  Liuwei
 * @version 1.0.1
 * @date    2023-05-17
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-05-17 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */

#ifndef __MODBUS_APP_H_
#define __MODBUS_APP_H_

/* file includes -------------------------------------------------------------*/
#include <stdint.h>
/* cplusplus -----------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/* macro/define/typedef ------------------------------------------------------*/
#define RTU_DATA_SIZE      (256)

typedef struct 
{
    uint8_t addr ;
    uint8_t cmd_code;
    uint16_t reg_addr;
    uint16_t data_len;  // 寄存器长度
	uint16_t data_size; // 数据长度
    uint16_t data_buf[RTU_DATA_SIZE];
}md_data_type;

/* variables -----------------------------------------------------------------*/

/*******************************************************************************
 * public API List
 ******************************************************************************/
uint8_t modbus_rtu_analysis(uint8_t *rx_buf ,uint16_t rx_num , md_data_type *recv_data);
uint16_t modbus_calc_crc(uint8_t *ptr, uint16_t len);

#ifdef __cplusplus
}
#endif

#endif  /* #ifndef __MODBUS_APP_H_ */
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/
